package com.mt.recursion;

import com.sun.org.apache.regexp.internal.RE;

/**
 * 递归获取最大值
 */
public class GetMax {

    public static int getMax(int[] arr){
        return process(arr,0,arr.length-1);
    }

    public static int process(int[] arr,int L,int R){
        if (L == R){
            return arr[L];
        }
        int mid = L+((R-L)>>1);
        int LMax = process(arr,L,mid);
        int RMax = process(arr,mid+1,R);
        return Math.max(LMax,RMax);
    }

    public static void main(String[] args) {
        int[] arr={1,2,3,4};
        int max = getMax(arr);
        System.out.println(max);
    }

}
